package com.tanhua.dubbo.server.controller;

import com.tanhua.dubbo.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @ClassName: BaiduController
 * @Author:王晨晗
 * @Description: 百度接口
 * @Date: 2022/01/08/17:21
 */
@RestController
@RequestMapping("baidu")
public class BaiduController {
    @Autowired
    private BaiduService baiduService;

    /**
     * @description 更新用户地理位置
     * @param param
     * @return
     */
    @PostMapping("location")
    public ResponseEntity updateLocation(@RequestBody Map<String , Object> param){
        Double longitude = Double.valueOf(param.get("longitude").toString());   //经度
        Double latitude = Double.valueOf(param.get("latitude").toString());     //纬度
        String address = param.get("addrStr").toString();

        baiduService.updateLocation(longitude , latitude , address);
        return ResponseEntity.ok(null);
    }
}
